package com.ruoyi.web.controller.his;

import java.util.ArrayList;
import java.util.List;

import com.ruoyi.his.domain.WarnHospitalLog;
import com.ruoyi.his.domain.WarnPreLog;
import com.ruoyi.his.domain.vo.WarnMenuItemVo;
import com.ruoyi.his.service.IWarnHospitalLogService;
import com.ruoyi.his.service.IWarnPreLogService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.HisEngineRuleGroup;
import com.ruoyi.system.service.IHisEngineRuleGroupService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 预警规则组合Controller
 * 
 * @author Alan
 * @date 2024-03-07
 */
@RestController
@RequestMapping("/system/group")
public class HisEngineRuleGroupController extends BaseController
{
    @Autowired
    private IHisEngineRuleGroupService hisEngineRuleGroupService;

    /**
     * 查询预警规则组合列表
     */
//    @PreAuthorize("@ss.hasPermi('system:group:list')")
    @GetMapping("/list")
    public TableDataInfo list(HisEngineRuleGroup hisEngineRuleGroup)
    {
        startPage();
        List<HisEngineRuleGroup> list = hisEngineRuleGroupService.selectHisEngineRuleGroupList(hisEngineRuleGroup);
        return getDataTable(list);
    }

    @GetMapping("/getRuleGroupList")
    public TableDataInfo getRuleGroupList()
    {

        List<HisEngineRuleGroup> list = hisEngineRuleGroupService.selectHisEngineRuleGroupMyList();
        return getDataTable(list);
    }
    /**
     * 导出预警规则组合列表
     */
//    @PreAuthorize("@ss.hasPermi('system:group:export')")
    @Log(title = "预警规则组合", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(HisEngineRuleGroup hisEngineRuleGroup)
    {
        List<HisEngineRuleGroup> list = hisEngineRuleGroupService.selectHisEngineRuleGroupList(hisEngineRuleGroup);
        ExcelUtil<HisEngineRuleGroup> util = new ExcelUtil<HisEngineRuleGroup>(HisEngineRuleGroup.class);
        return util.exportExcel(list, "预警规则组合数据");
    }

    /**
     * 获取预警规则组合详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:group:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(hisEngineRuleGroupService.selectHisEngineRuleGroupById(id));
    }

    /**
     * 新增预警规则组合
     */
//    @PreAuthorize("@ss.hasPermi('system:group:add')")
    @Log(title = "预警规则组合", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HisEngineRuleGroup hisEngineRuleGroup)
    {
        return toAjax(hisEngineRuleGroupService.insertHisEngineRuleGroup(hisEngineRuleGroup));
    }

    /**
     * 修改预警规则组合
     */
//    @PreAuthorize("@ss.hasPermi('system:group:edit')")
    @Log(title = "预警规则组合", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HisEngineRuleGroup hisEngineRuleGroup)
    {
        return toAjax(hisEngineRuleGroupService.updateHisEngineRuleGroup(hisEngineRuleGroup));
    }

    /**
     * 删除预警规则组合
     */
//    @PreAuthorize("@ss.hasPermi('system:group:remove')")
    @Log(title = "预警规则组合", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hisEngineRuleGroupService.deleteHisEngineRuleGroupByIds(ids));
    }
}
